<template>
  <div>
    <el-input
      style="width: 200px"
      v-model="input"
      placeholder="请输入内容"
    ></el-input>
    <el-button type="primary" size="small">查询</el-button>
    <el-button type="primary" size="small">添加</el-button>
    <el-button type="primary" size="small">重置</el-button>
    <el-table :data="tableData" border>
      <el-table-column prop="id" label="ID"> </el-table-column>
      <el-table-column prop="name" label="商品名称"> </el-table-column>
      <el-table-column prop="retail_price" label="售价"> </el-table-column>
      <el-table-column prop="goods_number" label="库存"> </el-table-column>
      <el-table-column label="新品">
        <template slot-scope="{ row }">
          {{ row.is_new === 1 ? "是" : "否" }}
        </template>
      </el-table-column>
      <el-table-column label="人气">
        <template slot-scope="{ row }">
          {{ row.is_hot === 1 ? "是" : "否" }}
        </template>
      </el-table-column>
      <el-table-column label="上架">
        <template slot-scope="{ row }">
          {{ row.is_delete === 1 ? "否" : "是" }}
        </template>
      </el-table-column>
      <el-table-column prop="retail_price" label="排序"> </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="{ row }"
          ><el-button type="primary" size="small" @click="editFn(row.id)"
            >编辑</el-button
          ></template
        >
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getAdminGoods } from "../../../request/api";
export default {
  data() {
    return {
      tableData: [],
      input: "",
    };
  },
  created() {
    getAdminGoods({
      page: 1,
      name: "",
      size: 10,
    }).then((res) => {
      if (res.errno === 0) {
        console.log(res);
        this.tableData = res.data.data;
      }
    });
  },
  methods: {
    editFn(id) {
      console.log(id);
      this.$router.push(`/editgood/${id}`)
    },
  },
};
</script>
 
<style lang = "less" scoped>
</style>